<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<%
	String grpId = request.getParameter("grpId");
%>
<html>
	<head>
		<script type="text/javascript">
		
			$(function(){
				//加载两个要使用json分页的组件
		        loadGird("frm", 1);
			})
				
			var callback_frm = function(rows, frm) {
		       $.each(rows, function(i, n){
		    	   var row = $("#"+frm+" .template").clone().removeClass("template");
		   			       var keyValue = n.id;
			       row.find(".klId").attr("value",n.id);
			   	
			       row.find(".klart_name").text(n.art_name);
			   	
			       row.find(".klcreate_time").text(n.create_time);
			   	
		 		   row.attr("id","ready"+i);
		           row.attr("class","tr_nbw");
		           row.appendTo("#"+frm+" .grid");
		       });   
			}
			
			var remarticles = function(){
				var options = {
				type: 'POST',
				async: false,
				dataType: 'content-type',
				success: function(msg) {
						alert("成功移除"+msg+"条记录!");
						document.getElementById("frm").action="<%=path%>/cms/artgroup/grpArtlst?grpId=<%=grpId %>"
						loadGird("frm", 1);
					}
				}
				if(confirm('您确认要移除吗？')){
					document.getElementById("frm").action="<%=path%>/cms/artgroup/remArt?grpId=<%=grpId %>";
					$('#frm').ajaxSubmit(options);
				}
			}
			function addarticles(){
				opendailog("{src:'<%=path%>/cms/artgroup/get/artList',title:'文章属性',width:600,height:300,savefunc:'savefunc'}",window);
			}
			
			function savefunc(frame){
				var retval = frame.contentWindow.getselectids();
				if(retval!=""){
					$.ajax({
					   type: "POST",
					   url: "<%=path %>/cms/artgroup/addArt",
					   data: "grpId=<%=grpId %>&artIds="+retval,
					   success: function(msg){
					   		reloadGrid("frm", 1);
					   }
					});
				}
				return "success";
			}
		    
		    function seach(){
		    	var seachv = document.getElementsByName("seachv");
		    	var url = $("#frm").attr("action")+"&seachv="+seachv.vlaue;
		    	$("#"+frm).attr("action",url);
		    	loadGird("frm", 1);
		    }
			
		</script>
	</head>
<body>
<form name="frm" method="post" style="margin: 0" action="<%=path%>/cms/artgroup/grpArtlst?grpId=<%=grpId %>" id="frm">
		<table width="100%">
			<tr>
				<td height="2px"></td> 
			</tr>
			<tr>
				<td >
					<input type="text" name="seachv" id="seachv" value="${seachv }"/>
					<input type="button" onclick="seach()" class="button4_nbw" value="查 询" />
				</td> 
				<td align="right">
					<input type="button" onclick="addarticles();" class="button4_nbw" value="添加" />
					<input type="button" onclick="remarticles()" class="button4_nbw" value="移除" />
					&nbsp;&nbsp;
				</td>
			</tr>
		</table>
		<center>
		<table><tr><td height="2px"></td></tr></table>
		<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
			<thead class="th_nbw">
				<tr >
					<td width="40px" >
						<input type="checkbox" class="allCheck" />
					</td>
		      		<td>
						文章名称
					</td>   
		      		<td>
						创建时间
					</td>   
				</tr>
			</thead>
			<tbody>
				<tr class="template klId">
					<td width="40px" class="idCheck">
						<input type="checkbox" name="chk" class="klId" />
					</td>
		   		    <td class="klart_name niceTable-left"></td>
		   		    <td class="klcreate_time niceTable-left"></td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td style="border-right: none">
						<img class="loading"
							src="/resources/skins/default/images/large-loading.gif" width="20px"
							class="hidden" />
					</td>
					<td colspan="2" style="border-left: none" class="txtRight">
						<span class="pagediv"></span>
					</td>
				</tr>
			</tfoot>
		</table>
		</center>
	</form>
</body>
</html>
